//
//  ZZBaseViewController.swift
//  sina
//
//  Created by 张鹏 on 16/5/22.
//  Copyright © 2016年 ZP. All rights reserved.
//

import UIKit

class ZZBaseViewController: UITableViewController,ZZVisitorLoginViewDelegate  {

    //根据用户是否登录显示登录页面/访客视图页面
    var userLogin = ZZUserAccountViewModel.sharedAccountViewModel.userAccount != nil
    //添加访客视图的属性
    lazy var visitorView : ZZVisitorLoginView = ZZVisitorLoginView()
    
    //判断
    override func loadView() {
//        super.loadView()
        
        if userLogin {
            super.loadView()
        }else {
        //加载访客视图
        self.loadVisitorView()
            
        }
    }
    
    //TODO: Swift中代理协议方法必须要实现,如果不实现就会报错
    //用户登录的协议代理方法
    func userWilllogin(){
        
        let oauth = ZZOAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)

    }
    //用户注册的协议代理方法
    func userWiilRegister(){
        
        //给ZZOAuthViewController嵌套一个UINavigationController控制器
        
        let oauth = ZZOAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        
        presentViewController(nav, animated: true, completion: nil)
    
    }
    
  private func loadVisitorView() {
    view = visitorView
    visitorView.visitorDelegate = self
    
    }
    
   override func viewDidLoad() {
        super.viewDidLoad()
    
    }
   
}
